home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gwu / arith.h < prev    next >
C/C++ Source or Header  |  1996-01-30  |  1KB  |  49 lines

  1. /*
  2.  * Copyright (C) 1985-1992  New York University
  3.  * 
  4.  * This file is part of the Ada/Ed-C system.  See the Ada/Ed README file for
  5.  * warranty (none) and distribution info and also the GNU General Public
  6.  * License for more details.
  7.  
  8.  */
  9. /* Translation of module ada - arith to C */
  10. /* David Shields  CIMS    11 Nov 83 */
  11.  
  12. /* translation of arith and multi-precision package to C.
  13.  *
  14.  */
  15. #ifndef _arith_h
  16. #define _arith_h
  17. #include <math.h>
  18.  
  19. /*
  20.   Some of the procedures want to signal overflow by returning the
  21.   string 'OVERFLOW'. In C we do this by setting global arith_overflow
  22.   to non-zero if overflow occurs, zero otherwise
  23.  */
  24. extern int arith_overflow ;
  25.  
  26.  
  27. #define ABS(x) ((x)<0 ? -(x) : (x))
  28. #define SIGN(x) ((x)<0 ? -1 : (x)==0 ? 0 : 1)
  29.  
  30. /* Constants for use by arithmetic packages: */
  31.  
  32. typedef struct Rational_s
  33. {
  34.     int    *rnum;    /* numerator */
  35.     int    *rden;    /* denominator */
  36. } Rational_s;
  37. typedef Rational_s *Rational;
  38.  
  39. /* Macros for access to rational numbers: */
  40.  
  41. #define num(x) x->rnum
  42. #define den(x) x->rden
  43.  
  44.  
  45. extern Rational RAT_TWO;
  46. extern    Rational ADA_MAX_FLOAT;
  47.  
  48. #endif
  49.